<%@taglib tagdir="/WEB-INF/tags/apus" prefix="apus" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@tag description="phone number info" pageEncoding="UTF-8"%>
<fmt:setLocale value="${lang}"/>
<div class="well">
    <div>
        <h2 class="pull-left">
            <c:url var="subURL" value="main">
                <c:param name="action" value="${phoneNumber.getOwner().getSubscriberType()}.view"/>
                <c:param name="id" value="${phoneNumber.getOwner().id}"/>
            </c:url>
            <apus:only-user role="ADMIN"><a href="${subURL}"><c:out value="${phoneNumber.getOwner().name}"/></a>
                &nbsp;</apus:only-user>
            <c:out value="${phoneNumber.number}"/></h2>
        <apus:only-user role="ADMIN"><a class="btn btn-small pull-right" href="main?action=phoneNumber.list"> <i class="icon-arrow-left"></i><fmt:message key="to.numbers.list"/> </a></apus:only-user>
        <apus:only-user role="USER"><a class="btn btn-small pull-right" href="main?action=main.view"> <i class="icon-arrow-left"></i> <fmt:message key="back"/> </a></apus:only-user>
    </div>
</div>

<div class="well">
    <h3 class="pull-left"><fmt:message key="outgoing.calls"/></h3>
    <table class="table table-condensed table-striped table-bordered">
        <thead>
            <tr>
                <th><fmt:message key="in.number"/></th>
                <th><fmt:message key="date"/></th>
                <th><fmt:message key="time"/></th>
                <th><fmt:message key="duration"/></th>
            </tr>
        </thead>
        <tbody>
            <c:if test="${!phoneNumber.outCalls.isEmpty()}">
                <c:forEach var="call" items="${phoneNumber.outCalls}">
                    <tr>
                        <c:url var="callURL" value="main">
                            <c:param name="action" value="phoneNumber.view"/>
                            <c:param name="id" value="${call.numberTo.id}"/>
                        </c:url>
                        <td>
                            <apus:only-user-href href="${callURL}" role="ADMIN"><c:out value="${call.numberTo}"/></apus:only-user-href>
                        </td>
                        <td>
                            <fmt:formatDate value="${call.dateOfCall}" type="date" dateStyle="medium"/>
                        </td>
                        <td>
                            <fmt:formatDate value="${call.dateOfCall}" type="time" timeStyle="medium"/>
                        </td>
                        <td>
                            <c:out value="${call.duration}"/>
                        </td>
                    </tr>
                </c:forEach>
            </c:if>
        </tbody>

    </table>

    <h3 class="pull-left"><fmt:message key="incoming.calls"/></h3>
    <table class="table table-condensed table-striped table-bordered">
        <thead>
            <tr>
                <th><fmt:message key="out.number"/></th>
                <th><fmt:message key="date"/></th>
                <th><fmt:message key="time"/></th>
                <th><fmt:message key="duration"/></th>
            </tr>
        </thead>
        <tbody>
            <c:if test="${!phoneNumber.inCalls.isEmpty()}">
                <c:forEach var="call" items="${phoneNumber.inCalls}">
                    <tr>
                        <c:url var="callURL" value="main">
                            <c:param name="action" value="phoneNumber.view"/>
                            <c:param name="id" value="${call.numberFrom.id}"/>
                        </c:url>
                        <td>
                            <apus:only-user-href href="${callURL}" role="ADMIN"><c:out value="${call.numberFrom}"/></apus:only-user-href>
                        </td>
                        <td>
                            <fmt:formatDate value="${call.dateOfCall}" type="date" dateStyle="medium"/>
                        </td>
                        <td>
                            <fmt:formatDate value="${call.dateOfCall}" type="time" timeStyle="medium"/>
                        </td>
                        <td>
                            <c:out value="${call.duration}"/>
                        </td>
                    </tr>
                </c:forEach>
            </c:if>
        </tbody>

    </table>
</div>